package sg.edu.nus.iss.team2s.jass.gui;


import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Panel;
import java.util.List;
import java.util.Iterator;
import sg.edu.nus.iss.team2s.jass.dto.JobAdvert;

/**
*
* @author Aye Thazin Kyaw
* @version 1.1
*
*/
public class JobAdvertSearchList extends Panel{

	private static final long serialVersionUID = 1L;
	private Panel parent = null;

	/**
	 * This is the default constructor
	 */
	
	public JobAdvertSearchList(Panel parent) {
		super();
		this.parent = parent;
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(492, 23);
		this.setLayout(new GridBagLayout());
	}
	public void displayResult(List<JobAdvert> list)
	{
		//SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("dd-MMM-yyyy");

		parent.removeAll();
		
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		JobAdvertSearchItemTitle title1 = new JobAdvertSearchItemTitle();
		this.add(title1, gridBagConstraints);
		
		int currentRow = 1;
		Iterator<JobAdvert> iterator = list.iterator();
		while(iterator.hasNext())
		{
			gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = currentRow++;
	
			JobAdvert jobAdvert = iterator.next();
			JobAdvertSearchItem transaction = new JobAdvertSearchItem(this, jobAdvert);
			this.add(transaction, gridBagConstraints);
		}
		parent.add(this);
		parent.validate();
	}
	
	
}
